Skip to content

Fix one-timestep logging skew and document GetTorque() sign convention - #5

Merged
salhus merged 2 commits into
mainfrom
copilot/fix-per-step-logging-bug
Jul 8, 2026
Merged

Fix one-timestep logging skew and document GetTorque() sign convention#5
salhus merged 2 commits into
mainfrom
copilot/fix-per-step-logging-bug

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Per-step CSV logging in demo_vgoswec.cpp mixed pre-step kinematics with post-step torque/time, skewing every row by one timestep (~0.005 s) and making power_w = -tau*omega incorrect. Both the GUI (ui.IsRunning) and headless loops had identical bugs.

Changes (src/demo_vgoswec.cpp only)

  • Bug 1 — logging skew (both loops): Move rsda->GetAngle() / rsda->GetVelocity() to after DoStepDynamics, grouping all four logged reads post-step:
// Before: pitch_rad/pitch_vel read PRE-step → one-sample skew vs. time/torque
const double pitch_rad = rsda->GetAngle();
const double pitch_vel = rsda->GetVelocity();
system.DoStepDynamics(dt);
// ...
const double pto_tau = rsda->GetTorque();  // post-step

// After: all quantities sampled at the same post-step timestamp
system.DoStepDynamics(dt);
// ...
const double pitch_rad = rsda->GetAngle();
const double pitch_vel = rsda->GetVelocity();
const double exc_tau   = exc_provider->GetLatestExcitationTorque();
const double pto_tau   = rsda->GetTorque();
  • Bug 2 — sign convention (both loops): Add a comment above rsda->GetTorque() documenting the expected sign per docs/CONTROLLERS.md (positive torque opposes positive θ; P_abs = −τ·ω) and the passive-run validation: pto_torque_nm should carry the opposite sign to flap_pitch_vel_rads, yielding net-positive power_w. No preemptive negation — comment only.

Copilot AI changed the title [WIP] Fix per-step logging bug in simulation loops Fix one-timestep logging skew and document GetTorque() sign convention Jul 8, 2026
Copilot finished work on behalf of salhus July 8, 2026 00:08
Copilot AI requested a review from salhus July 8, 2026 00:08
@salhus
salhus marked this pull request as ready for review July 8, 2026 00:11
@salhus
salhus merged commit bfc84df into main Jul 8, 2026
@salhus
salhus deleted the copilot/fix-per-step-logging-bug branch July 8, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants